package com.sff.system {
	
	import com.sff.core.sff_internal;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.utils.Dictionary;
	
	public final class SoundSystemClass extends EventDispatcher {
		
		private static var instance : SoundSystemClass;
		
		private var _muted	:Boolean = true;
		private var _volume	:Number = 1;
		
		public function SoundSystemClass( ) {
			if( instance != null ) {
				throw new Error( "singleton class" );
			}
		}
		
		public static function start( ) : SoundSystemClass {
			if (instance == null) {
				instance = new SoundSystemClass();
			}
			return instance;
		}
		
		sff_internal function set volume(value:Number):void {		
			if (isNaN(value) && value >= 0 && value <= 1 && value != _volume) {
				_volume = value;				
				dispatchEvent(new Event(Event.CHANGE));
			}
		}
		
		sff_internal function get volume():Number {
			return _volume;
		}
		
		
		sff_internal function set muted(value:Boolean):void {			
			if (_muted != value) {
				_muted = value;
				dispatchEvent(new Event(_muted ? Event.OPEN : Event.CLOSE));
			}			
		}
		
		sff_internal function get muted():Boolean {
			return _muted;
		}				
	}
}